﻿layui.define(['jquery', 'form'], function (exports) {
    var $ = layui.jquery;

    var count = {
        compareDate: function (date1, date2, hdate1, hdate2) {
            var start = new Date(date1);
            var end = new Date(date2);
            var hstart = new Date(hdate1);
            var hend = new Date(hdate2);
            if (hstart != undefined && start.getTime() > hstart.getTime()) {
                layer.msg("开始时间晚于假期开始时间", { icon: 2 });
            } else if (hdate2 != undefined && end.getTime() < hend.getTime()) {
                layer.msg("结束时间早于假期结束时间", { icon: 2 });
            }
            else if (start.getTime() >= end.getTime()) {
                layer.msg("开始时间晚于结束时间", { icon: 2 });
            } else {
                if (date1 != "" && date2 != "") {
                    var day = (end - start) / (1000 * 60 * 60 * 24) + 1;
                    $("#days").text("假期共" + day + "天");
                } 
                return;
            }
            $('#StartDate').val('');
            $('#EndDate').val('');            
            $("#days").text("");            
        }


    };
    exports('count', count);
})